package com.ocean.courtyard.core.hook;

import com.ocean.courtyard.entity.CourtyardHome;
import com.ocean.courtyard.message.Message;
import lombok.Getter;
import net.william278.huskhomes.api.HuskHomesAPI;
import net.william278.huskhomes.position.Position;
import net.william278.huskhomes.position.World;
import net.william278.huskhomes.user.OnlineUser;
import org.bukkit.entity.Player;

@Getter
public class HuskHomeApiHook {

    private final HuskHomesAPI huskHomesAPI;

    private final Message message;

    public HuskHomeApiHook(Message message) {
        this.message = message;
        this.huskHomesAPI = HuskHomesAPI.getInstance();
    }

    public void teleportPlayer(Player player, World world, CourtyardHome home) {
        OnlineUser onlineUser = huskHomesAPI.adaptUser(player);
        Position position = Position.at(home.getX(), home.getY(), home.getZ(), world, home.getServer());
        huskHomesAPI.teleportBuilder().teleporter(onlineUser).target(position).buildAndComplete(false);
    }
}
